const mongoose = require('./db/index').mongoose;
const { hospitalModel } = require('./db/models/cosmetic');

async function testHospitalCategories() {
  try {
    console.log('测试医院分类数据...');
    
    // 等待数据库连接
    await new Promise(resolve => setTimeout(resolve, 1000));
    
    // 获取所有分类
    const categories = await hospitalModel.distinct('category');
    console.log('所有医院分类:', categories);
    
    // 检查每个分类的医院数量
    for (const category of categories) {
      const count = await hospitalModel.countDocuments({ category });
      console.log(`${category}: ${count} 个医院`);
      
      // 显示前3个医院的名称
      const hospitals = await hospitalModel.find({ category }).limit(3);
      hospitals.forEach(hospital => {
        console.log(`  - ${hospital.name}`);
      });
    }
    
  } catch (error) {
    console.error('测试失败:', error);
  } finally {
    mongoose.connection.close();
  }
}

testHospitalCategories();

